<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>定位</title>
    <!-- 
         相对限制绝对
            => 父容器设置为相对定位
            => 子元素设置为绝对定位
               子元素只能在父容器移动位置
    
    -->
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        div {
            margin: 30px;
        }

        .box {
            width: 600px;
            height: 400px;
            border: 1px solid red;
            position: relative;

        }

        .box1 {
            width: 400px;
            border: 1px solid blue;
        }

        .box2 {
            width: 400px;
            border: 1px solid green;
            /* 绝对定位 */
            position: absolute;
            /* top:300px;
            left:100px; */
            bottom: 30px;
            right:10px;
        }

        .box3 {
            width: 400px;
            border: 1px solid blueviolet;

            /* 相对定位 */
            position: relative;
            top:50px;
            left:50px;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="box1">盒子一</div>
        <div class="box2">盒子二</div>
        <div class="box3">盒子三</div>
    </div>
</body>

</html>